package com.woniu.p2p.excelservice;

import com.woniu.p2p.entity.InvestRepay;
import com.woniu.p2p.entity.UserMonloans;
import com.woniu.p2p.mapper.InvestRepayMapper;
import com.woniu.p2p.mapper.UserMonloansMapper;
import com.woniu.p2p.vo.UserRepayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class InRepayService {

    @Autowired
    UserMonloansMapper userMonloansMapper;
    @Autowired
    InvestRepayMapper investRepayMapper;


    public void readExcel(UserRepayVo userRepayVo) {
        Integer loansId = userRepayVo.getLoansId();
        String repayName = userRepayVo.getRepayName();
        InvestRepay allByName = investRepayMapper.findAllByName(repayName);
        Integer repayId = allByName.getRepayId();
        int userId=2;
        Date monloansTime = userRepayVo.getMonloansTime();
        long monloansPaymonth = userRepayVo.getMonloansPaymonth();
        long monloansPaybefore = userRepayVo.getMonloansPaybefore();
        long monloansPaynow = userRepayVo.getMonloansPaynow();
        long monloansPaynext = userRepayVo.getMonloansPaynext();
        String monloansMonth = userRepayVo.getMonloansMonth();
        String monloansLastmonth = userRepayVo.getMonloansLastmonth();
        String monloansStatus = userRepayVo.getMonloansStatus();
        long monloansBalance = userRepayVo.getMonloansBalance();
        UserMonloans userMonloans = new UserMonloans( userId,  loansId,  repayId,  monloansTime,  monloansPaymonth,  monloansPaybefore,  monloansPaynow,  monloansPaynext,  monloansMonth,  monloansLastmonth,  monloansStatus,  monloansBalance);
        userMonloansMapper.insert(userMonloans);
    }

}
